package  org.fantasy.cpp.core.pojo;

import org.dom4j.Document;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Table;

import  org.fantasy.cpp.core.annotation.Field;
import  org.fantasy.common.util.XMLUtil;

/**
 * 表格配置
 * 
 * @author 王文成
 * @version 1.0
 * @since 2011-7-5
 */
@Table("TABLE_CONFIG")
public class TableConfig {

	@Id
	@Column("table_id")
	@Field(desc = "表格id", nullable = false)
	private Long tableId;

	@Column("table_code")
	@Field(desc = "表格编码", nullable = false, maxlenth = 128)
	private String tableCode;

	@Column("table_name")
	@Field(desc = "表格名称", nullable = false, maxlenth = 256)
	private String tableName;

	@Column("table_config")
	@Field(desc = "表格配置", nullable = true)
	private String tableConfig;

	@Column("table_desc")
	@Field(desc = "表格描述", nullable = true, maxlenth = 1024)
	private String tableDesc;

	@Column("table_sort_id")
	@Field(desc = "表格分类", nullable = true)
	private Long tableSortId;

	@Column("table_type_id")
	@Field(desc = "表格类型", nullable = true)
	private Long tableTypeId;

	@Column("create_date")
	@Field(desc = "创建日期", nullable = false)
	private java.util.Date createDate;

	@Column("state")
	@Field(desc = "状态", nullable = true, maxlenth = 8)
	private String state;

	public Long getTableId() {
		return tableId;
	}

	public void setTableId(Long tableId) {
		this.tableId = tableId;
	}

	public String getTableCode() {
		return tableCode;
	}

	public void setTableCode(String tableCode) {
		this.tableCode = tableCode;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getTableConfig() {
		return tableConfig;
	}

	public void setTableConfig(String tableConfig) {
		this.tableConfig = tableConfig;
	}

	public String getTableDesc() {
		return tableDesc;
	}

	public void setTableDesc(String tableDesc) {
		this.tableDesc = tableDesc;
	}

	public Long getTableSortId() {
		return tableSortId;
	}

	public void setTableSortId(Long tableSortId) {
		this.tableSortId = tableSortId;
	}

	public Long getTableTypeId() {
		return tableTypeId;
	}

	public void setTableTypeId(Long tableTypeId) {
		this.tableTypeId = tableTypeId;
	}

	public java.util.Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(java.util.Date createDate) {
		this.createDate = createDate;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public Document toDocument() throws Exception {
		StringBuilder xml = new StringBuilder(1024);
		xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		xml.append("<table>\n");
		xml.append(getTableConfig());
		xml.append("</table>\n");
		return XMLUtil.fromXML(xml.toString(), "UTF-8");
	}

}